define(function(require,exports,module){
	var add = require('module/home/addition/add.js');
	require('shadow');
	exports.init = function(){

	}	
	exports.operate = function(){

		//广告位的特效 
		adv_shadow();

		//div方位进出
		food_hover();

		//hover在div上时，阴影效果任然保留
		info_div_hover();

		//加入我们处的样式
		join_us();

		//点击1F 2F 3F 4F的图片跳转商品详细页面
		click_to_food_detail();

	}
	exports.win_resize = function(){

	}	
	function adv_shadow(){
		var adv_arr = Array('.footer_adv_pic','.center_adv_pic');
		for (var i = adv_arr.length - 1; i >= 0; i--) {
			$(adv_arr[i]).live('mouseenter',function(){
				var img_obj = $(this).find("img");
				img_obj.removeClass("no_shadow");
				img_obj.shadow("raised");
			});
			$(adv_arr[i]).live('mouseleave',function(){
				var img_obj = $(this).find("img");
				img_obj.addClass("no_shadow");
			});
		};
	}

	function food_hover(){
		$(".classify ul li").live('mouseenter mouseleave',function(e){
			var w = $(this).width();
			var h = $(this).height();
			var x = (e.pageX - this.offsetLeft - (w / 2)) * (w > h ? (h / w) : 1);
			var y = (e.pageY - this.offsetTop - (h / 2)) * (h > w ? (w / h) : 1);
			var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
			var eventType = e.type;
			var div_obj = $(this).find("div");
			if(e.type == 'mouseenter'){
				div_obj.css("display","inline-block");
				switch (direction) {
				  case 0:
				  		div_obj.css("top","-150px");
				  		div_obj.css("left","0px");
						div_obj.stop().animate({
							top:"0px"
						},500);
					break;
				  case 1:
				  		div_obj.css("top","0px");
				  		div_obj.css("left","150px");
						div_obj.stop().animate({
							left:"0px"
						},500);
						break;
				  case 2:
				  		div_obj.css("top","150px");
				  		div_obj.css("left","0px");
						div_obj.stop().animate({
							top:"0px"
						},500);
						break;
				  case 3:
				  		div_obj.css("top","0px");
				  		div_obj.css("left","-150px");
						div_obj.stop().animate({
							left:"0px"
						},500);
					break;
				}

			}else{
				switch (direction) {
				  case 0:
						div_obj.stop().animate({
							top:"-130px",
							left:"0px"
						},500);
					break;
				  case 1:
						div_obj.stop().animate({
							left:"150px",
							top:"0px"
						},500);
						break;
				  case 2:;
						div_obj.stop().animate({
							top:"200px",
							left:"0px"
						},500);
						break;
				  case 3:
						div_obj.stop().animate({
							left:"-150px",
							top:"0px"
						},500);
					break;
				}		
			}
		});
	}

	function info_div_hover(){
		$('.classify_info').live('hover',function(){
			$(this).prev().find("img").css("box-shadow","0px 0px 20px #D70000");
		}).live('mouseleave',function(){
			$(this).prev().find("img").css("box-shadow","0px 0px 20px #AAA");
		});
	}

	function join_us(){
		$("#accordion a").live("click",function(){
			var href = $(this).attr("href");
			var  str = href.substr(0,href.length-1);
			$("#collapse"+str).collapse('hide');
			$(href).collapse('show');
		});
	}

	function click_to_food_detail(){
		$(".classify ul li div").live('click',function(){
			var detail_url = $(this).prev().attr("href");
			window.location = detail_url;
		});
	}


})
